<template>
  <div>
    <van-nav-bar
     title="栏目管理"
     left-arrow
     @click-left="$router.back()"
     />
     <div>
         <p>已添加</p>
        <van-grid :gutter="5" column-num="6" :square="false">
        <van-grid-item v-for="(item,index) in labellist0" :key="item.id" :text="item.name" @click="deleFn(index)"/>
        </van-grid>
     </div>
     <div>
        <p>未添加</p>
        <van-grid :gutter="5" column-num="6"  :square="false">
        <van-grid-item v-for="(item,index) in labellist1" :key="item.id" :text="item.name" @click="addFn(index)"/>
        </van-grid>
     </div>
  </div>
</template>

<script>
// import {labelmanage} from '@/api/user'
export default {
    data(){
        return{
            labellist0:JSON.parse(localStorage.getItem('labellist0'))||[],
            labellist1:JSON.parse(localStorage.getItem('labellist1'))||[]
        }
    },
    // created(){
    //     labelmanage().then(res=>{
    //         this.labellist0=res.data.data
    //         // localStorage.removeItem("labellist0")
    //         // localStorage.removeItem("labellist1")
    //         localStorage.setItem('labellist0',JSON.stringify(this.labellist0))
    //     })
    // },
    methods:{
        deleFn(index){
            this.labellist1.push(this.labellist0[index])
            localStorage.setItem('labellist1',JSON.stringify(this.labellist1))
            this.labellist0.splice(index,1)
            localStorage.setItem('labellist0',JSON.stringify(this.labellist0))
        },
        addFn(index){
            this.labellist0.push(this.labellist1[index])
            localStorage.setItem('labellist0',JSON.stringify(this.labellist0))
            this.labellist1.splice(index,1)
            localStorage.setItem('labellist1',JSON.stringify(this.labellist1))
        }
    }
}
</script>

<style>

</style>